package cn.edu.pku.cs08.liudun.picventure;

import android.app.Application;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.RectF;

public final class AppConfig extends Application{
	public static final int PAINT_MAX_WIDTH = 100;
	public static final int PAINT_INITIAL_WIDTH = 10;
	public static final int PAINT_GESTURE_WIDTH = 20;
	
	public static final int SEAMS_NUM_PER_CARVE_MIN = 1;
	public static final int SEAMS_NUM_PER_CARVE_MAX = 10;
	public static final int SEAMS_NUM_PER_CARVE_INITIAL = 1;
	
	public static final int FLING_MIN_DISTANCE = 200; 
	
	public static final int REQUEST_CODE_LOADIMAGE = 1;
	
	public static final int OPTION_VERTICAL_CARVE = 0;
	public static final int OPTION_HORIZONTOAL_CARVE = 1;
	
	public static final RectF maxRectF = new RectF(0, 0, 999, 999);
	
	
		
	private Bitmap displayBmp = null;
	private Bitmap maskBmp = null;
	private boolean isNewMaskAvailable = false;
	
	private RectF screnPortraitRectF = null;
	private RectF screnLandscapeRectF = null;
	
	
	private int paintWidth = PAINT_INITIAL_WIDTH;
	
	private int seamsNum = SEAMS_NUM_PER_CARVE_INITIAL;
	
	public int getSeamsNum() {
		return seamsNum;
	}

	public void setSeamsNum(int seamsNum) {
		this.seamsNum = seamsNum;
	}

	public int getPaintWidth() {
		return paintWidth;
	}

	public void setPaintWidth(int paintWidth) {
		this.paintWidth = paintWidth;
	}

	public RectF getScrenRectF() {
		int orientation = this.getResources().getConfiguration().orientation;
		switch(orientation) {
		case Configuration.ORIENTATION_LANDSCAPE:
			return screnLandscapeRectF;
		case Configuration.ORIENTATION_PORTRAIT:
			return screnPortraitRectF;
		default:
			return screnPortraitRectF;
		}
	}

	public void setScrenPortraitRectF(RectF screnPortraitRectF) {
		this.screnPortraitRectF = screnPortraitRectF;
	}

	public void setScrenLandscapeRectF(RectF screnLandscapeRectF) {
		this.screnLandscapeRectF = screnLandscapeRectF;
	}

	public void setDisplayBmp(Bitmap b) {
		this.displayBmp = b;
	}
	
	public Bitmap getDisplayBmp() {
		return this.displayBmp;
	}
	
	public Bitmap getMaskBmp() {
		return maskBmp;
	}
	
	public Bitmap getEmptyMaskBmp() {
		if(displayBmp == null) {
			return null;
		}
		maskBmp = Bitmap.createBitmap(displayBmp.getWidth(), displayBmp.getHeight(), Bitmap.Config.ARGB_8888);
		return maskBmp;
	}
	
	public void setMaskBmp(Bitmap b) {
		this.maskBmp = b;
		this.isNewMaskAvailable = true;
	}	
	
	public boolean isNewMaskAvailable() {
		return this.isNewMaskAvailable;
	}
	
	public void consumeNewMask() {
		this.isNewMaskAvailable = false;
	}
}
